<h1><%=t ".title"%></h1>

<% form_tag materials_path, :method => 'get' do %>
  <p>
    <%= t('activerecord.attributes.material.material_type') %>
    <%= collection_select(:material, :material_type, @material_types, :id, :description, :include_blank => t('lbl_all'), :selected => @search_material_type.to_i) %>
    <%= t('activerecord.attributes.material.title') %>
    <%= text_field_tag :search_title, params[:search_title] %>
  </p>
  <p>
    <%= t('activerecord.attributes.material.isbn') %>
    <%= text_field_tag :search_isbn, params[:search_isbn] %>

    <%= t('activerecord.attributes.material.issn') %>
    <%= text_field_tag :search_issn, params[:search_issn] %>
    
    <%= submit_tag t('btn_search'), :name => nil %>
  </p>
<% end %>

<% if @total == 0 %>

<p><%= t('lbl_no_record_found') %></p>

<% else %>
  <p><%=t('lbl_count_record_found') + '<b>' + @total.to_s + '</b>'%></p>

    <table>
      <tr>
        <th><%= t('activerecord.attributes.material.title')%></th>
        <th><%= t('activerecord.attributes.material.sub_title')%></th>
        <th><%= t('activerecord.attributes.material.material_type')%></th>
        <th><%= t('activerecord.attributes.material.edition_number')%></th>
        <th><%= t('activerecord.attributes.material.edition_year')%></th>
        <th><%= t('activerecord.attributes.material.isbn')%></th>
        <th><%= t('activerecord.attributes.material.issn')%></th>
        <th><%= t('activerecord.attributes.material.price')%></th>
        <th><%= t('activerecord.attributes.material.currency')%></th>
      </tr>

    <% @materials.each do |material| %>
      <tr>
        <td><%=h material.title %></td>
        <td><%=h material.sub_title %></td>
        <% if  !material.material_type.nil? %>
          <td><%=h material.material_type.description %></td>
        <% else %>
          <td/>
        <% end %>
        <td><%=h material.edition_number %></td>
        <td><%=h material.edition_year %></td>
        <td><%=h material.isbn %></td>
        <td><%=h material.issn %></td>
        <td><%=h material.price %></td>
        <% if  !material.currency.nil? %>
          <td><%=h material.currency.name %></td>
        <% else %>
          <td/>
        <% end %>

        <td><%= link_to t('btn_show'), material %></td>
        <td><%= link_to t('btn_edit'), edit_material_path(material) %></td>
        <td><%= link_to t('btn_destroy'), material, :confirm => t('msg_sure_destroy?'), :method => :delete %></td>
      </tr>
    <% end %>
    </table>

<% end %>
    
<br />

<%= link_to t('.btn_new_material'), new_material_path %>